# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=revsh
pkgver=267.36a9a90
pkgrel=1
pkgdesc='A reverse shell with terminal support, data tunneling, and advanced pivoting capabilities.'
groups=('blackarch' 'blackarch-backdoor' 'blackarch-networking')
url='https://github.com/emptymonkey/revsh/'
arch=('x86_64' 'aarch64')
license=('MIT')
depends=('openssl')
makedepends=('git')
source=("git+https://github.com/emptymonkey/$pkgname.git"
        'git+https://github.com/openssl/openssl.git')
sha512sums=('SKIP'
            'SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -i 's|/usr/local|/usr/|g' Makefile

  # just for now
  sed -i 's|-static||' Makefile
}

build() {
  cd openssl

  ./config no-shared -static
  make

  cd "$srcdir/$pkgname"

  make
}

package() {
  cd $pkgname

  make DESTDIR="$pkgdir" install

  install -Dm 755 $pkgname "$pkgdir/usr/bin/$pkgname"
  install -Dm 755 in_the_key_of_c "$pkgdir/usr/bin/revsh-in_the_key_of_c"
  install -Dm 644 Documentation/revsh.1 "$pkgdir/usr/share/man/man1/revsh.1"

  rm "Documentation/$pkgname.1"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" INSTALL Documentation/*
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

